package com.jinduplan.planmanager.widgets

import android.app.Activity
import android.graphics.Bitmap
import com.baidu.mapapi.map.*
import com.cxz.kotlin.baselibs.base.MyBaseDialog
import com.cxz.kotlin.baselibs.base.changeDrawalbeColor
import com.huantansheng.easyphotos.EasyPhotos
import com.huantansheng.easyphotos.callback.SelectCallback
import com.jinduplan.planmanager.R
import kotlinx.android.synthetic.main.dialog_map_click_in.*
import java.lang.ref.WeakReference


class MapClickInDialog(
    context: Activity,
    addr: String,callback: SelectCallback
) : MyBaseDialog(
    context
) {

    val activity = context
    val mcallback = callback
    val addr = addr.run {
        tvLoc.setText(this)
    }



    override fun getContentId(): Int {
        return R.layout.dialog_map_click_in

    }


    val mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL
    override fun init() {
        ivLocation.setImageDrawable(R.mipmap.location.changeDrawalbeColor(context,R.color.grey_ccc))
        btnCancel.setOnClickListener {
            dismiss()
        }
        btnComfir.setOnClickListener {
            EasyPhotos.createCamera(activity , false).setFileProviderAuthority("com.jinduplan.planmanager.fileprovider").start(mcallback)
            dismiss()
        }

    }

    fun setBitMap(it: WeakReference<Bitmap>): MapClickInDialog {
        flMv.setImageBitmap(it.get())
        return this
    }

}